package com.lykj.lib_base.internal.utils

import com.blankj.utilcode.util.GsonUtils
import com.blankj.utilcode.util.LogUtils
import com.blankj.utilcode.util.Utils
import com.lykj.lib_base.data.model.ConfigModel
import java.io.*

/**
 * 读取Assets工具类
 */
object AssetsUtils {

    /**
     * 读取Assets/conf.json 内容
     */
    open fun readConfigJson(): ConfigModel? {
        var config: ConfigModel? = null

        try {
            val inputStream = Utils.getApp().assets.open("conf.json")
            val reader = InputStreamReader(inputStream)
            val jsonStr = reader.readText()
            config = GsonUtils.fromJson(jsonStr, ConfigModel::class.java)

            LogUtils.e("config json:${config.agent}")
        } catch (e: Exception) {
            e.printStackTrace()
        }

        return config
    }
}